﻿using UnityEngine;
using System.Collections;

public class scriptFacebookLogin : MonoBehaviour {

	// Use this for initialization
	void Start () {
        FB.Init(initFBDelegate, HideUnityDelegate, null);
	}
	
	// Update is called once per frame
	void Update () 
    {
	}

    public void CallBackLogin(FBResult result)
    {
        if (FB.IsLoggedIn)
        {
            print(FB.UserId);
        }
    }

    public void initFBDelegate()
    {
        if (!FB.IsLoggedIn)
        {
            FB.Login("email,publish_actions", CallBackLogin);
        }
    }

    public void HideUnityDelegate(bool isUnityHide)
    {
        if (isUnityHide)
        {
            Time.timeScale = 0;
        }
        else
        {
            Time.timeScale = 1;
        }
    }
}
